import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';

class ClipDemoPage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return ClipDemoPageState();
  }
}

class ClipDemoPageState extends State<ClipDemoPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text('圆角例子')),
      body: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        crossAxisAlignment: CrossAxisAlignment.center,
        children: <Widget>[
          Center(
            child: Text('BoxDecoration圆角'),
          ),
          Container(
            height: 100,
            width: 100,
            decoration: BoxDecoration(
                color: Colors.red,
                image: DecorationImage(
                    fit: BoxFit.cover,
                    image: AssetImage(
                      "static/gsy_cat.png",
                    )),
                borderRadius: BorderRadius.all(Radius.circular(5))),
          ),
          SizedBox(
            height: 10,
          ),
          Center(
            child: Text('BoxDecoration 圆角对child'),
          ),
          Container(
            height: 100,
            width: 100,
            decoration: BoxDecoration(
              color: Colors.red,
              borderRadius: BorderRadius.all(Radius.circular(10)),
            ),
            child: Image.asset(
              "static/gsy_cat.png",
              fit: BoxFit.cover,
              width: 100,
              height: 100,
            ),
          ),
          SizedBox(
            height: 10,
          ),
          Center(
            child: Text('ClipRRect 圆角对 child'),
          ),
          ClipRRect(
            borderRadius: BorderRadius.all(Radius.circular(5)),
            child: Image.asset(
              "static/gsy_cat.png",
              fit: BoxFit.cover,
              width: 100,
              height: 100,
            ),
          )
        ],
      ),
    );
  }
}
